package portal.mybatis.dao.service;

import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import portal.beans.HostGroup;
import portal.mybatis.dao.mapper.HostGroupMapper;

import java.util.List;
import java.util.Map;

@Service
public class HostGroupService {
    @Autowired
    HostGroupMapper hostGroupMapper;

    public int updateHostGroupById(HostGroup hostGroup){
        return hostGroupMapper.updateHostGroupById(hostGroup);
    }
    public int updateHostGroupById(int hostGroupId, String hostGroupName, String hostGroupIntroduction){
        HostGroup hostGroup = new HostGroup(hostGroupId, hostGroupName, hostGroupIntroduction);
        return hostGroupMapper.updateHostGroupById(hostGroup);
    }
    public List<HostGroup> selectById(int hostGroupId){
        return hostGroupMapper.selectById(hostGroupId);
    }
    public Integer insertHostGroup(HostGroup hostGroup){
        return hostGroupMapper.insertHostGroup(hostGroup);
    }
    public Integer insertHostGroup(String hostGroupName, String hosrGroupIntroduction){
        HostGroup hostGroup = new HostGroup(hostGroupName, hosrGroupIntroduction);
        return hostGroupMapper.insertHostGroup(hostGroup);
    }
    public int deleteById(HostGroup hostGroup){
        return hostGroupMapper.deleteById(hostGroup);
    }
    public int deleteById(int id){
        HostGroup hostGroup = new HostGroup();
        hostGroup.setHostGroupId(id);
        return hostGroupMapper.deleteById(hostGroup);
    }
    public List<HostGroup> showAll(){
        return hostGroupMapper.showAll();
    }
    public List<HostGroup> showPaged(int currPage, int pageSize) {
        Map<String, Object> data = new HashedMap();
        data.put("currIndex", (currPage-1)*pageSize);
        data.put("pageSize", pageSize);
        return hostGroupMapper.showPaged(data);
    }
    public Long countAll() {
        return hostGroupMapper.countAll();
    }
}
